package com.ctk.wifi.a.net;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import android.util.Log;

public class TCPSocketSend {
	/** Called when the activity is first created. */
	private String msg;

	public TCPSocketSend(String msg) {
		this.msg = msg;
	}

	public void send(String ip,int port) {

		Socket socket;
		try {
			socket = new Socket(ip, port);

			OutputStream ops = socket.getOutputStream();

			DataOutputStream dos = new DataOutputStream(ops);

			dos.write(msg.getBytes());
			Log.d("test", "send succ");
			dos.close();
		} catch (UnknownHostException e) {
			Log.d("test", "UnknownHostException");
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			Log.d("test", "IOException");
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			Log.d("test", "finally");
		}

	}
}